package html

import (
	"dog-blog/app/template/models"
	"dog-blog/app/template/services"
	"net/http"

	"github.com/gin-gonic/gin"
)

// HTMLIndex 首页
func HTMLIndex(ctx *gin.Context) {
	ctx.HTML(http.StatusOK, "blog/index.html", models.HTMLResp{CurrPage: "/"})
}

// HTMLAbout 关于
func HTMLAbout(ctx *gin.Context) {
	ctx.HTML(http.StatusOK, "blog/article.html", models.HTMLResp{CurrPage: "about", PostId: "YWJvdXQ="})
}

// HTMLArticle 文章
func HTMLArticle(ctx *gin.Context) {
	ctx.HTML(http.StatusOK, "blog/article.html", models.HTMLResp{CurrPage: "", PostId: ctx.Param("id")})
}

// HTMLList 文章列表
func HTMLList(ctx *gin.Context) {
	req := ctx.Request
	url := req.URL.String()
	htmlResp := services.GenArticleListParam(true, url)
	ctx.HTML(http.StatusOK, "blog/list.html", htmlResp)
}

// Search 搜索文章
func Search(ctx *gin.Context) {
	htmlResp := services.GenArticleListParam(false, ctx.Query("txt"))
	ctx.HTML(http.StatusOK, "blog/list.html", htmlResp)
}
